<template>
    <div>
        <van-nav-bar title="标题" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-button type="primary" @click="order(id)">预约</van-button>
    </div>
</template>

<script setup lang="ts">
import router from "../router/index";
import 'vant/es/Dialog/style';
import 'vant/es/toast/style';
import { Dialog, Toast } from 'vant'
import { yY } from '../api/index'
import { userInfoStore } from "../stores/userInfo";
import axios from "axios";

const onClickLeft = () => {
    history.back()
}

// pnina容器
const info = userInfoStore()
const { _id, nickname } = JSON.parse(sessionStorage.getItem('userInfo'))
console.log(_id,nickname);

// console.log(id);
// yY(id).then(res => {
//                 console.log(res);
//             })
// yY(id)

const order = (id: string) => {
    Dialog.confirm({
        title: '标题',
        message:
            '确定预约吗？',
    })
        .then(() => {
            // on confirm
            Toast.success('预约成功！');
            console.log(id);

            // yY(id).then(res => {
            //     console.log(res);
            // })
            axios.post('/api/users/yY', {
                id:_id,nickname
            }).then(res => {
                console.log(res);
            })

        })
        .catch((e) => {
            // on cancel
            Toast.fail('预约失败！' + e);
        });
}

</script>

<style scoped>

</style>